package sso.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {
    /*基于用户名查询用户信息
    * 查询到的用户信息,表中的字段名会作为map中key.字段名对应的只会作为map中的value存储*/
    @Select("select * from sys_user where username=#{username}")
    Map<String,Object> selectUserByUsername(@Param("username") String username);

    @Select("select m.permission from sys_menu m\n" +
            "    left join sys_role_menu on m.id=sys_role_menu.menu_id\n" +
            "    left join sys_user_role on sys_role_menu.role_id=sys_user_role.role_id\n" +
            "    left join sys_user on sys_user_role.user_id=sys_user.id")
    List<String> seelctUserPermissions(Long id);
}
